<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<div class="layuimini-container" style="height: 400px;">
    <div class="layuimini-main">
        <div class="layui-fluid">
            <fieldset class="layui-elem-field layui-field-title" style="color: #009688">
                <legend>车损信息</legend>
            </fieldset>
            <table class="layui-hide" id="cartInfoVerify" lay-filter="cartInfoVerify"></table>

            <fieldset class="layui-elem-field layui-field-title" style="color: #009688">
                <legend>物损信息</legend>
            </fieldset>
            <table class="layui-hide" id="objectInfoVerify" lay-filter="objectInfoVerify"></table>

            <fieldset class="layui-elem-field layui-field-title" style="color: #009688">
                <legend>人伤信息</legend>
            </fieldset>
            <table class="layui-hide" id="humanInfoVerify" lay-filter="humanInfoVerify"></table>

            <div style="float: right;font-size: 24px;font-weight: bold;">合计：<b id="sumMoney"></b>元</div>

            <button class="layui-btn layui-btn-warm" lay-submit lay-filter="backBtn">退回</button>
            <button class="layui-btn" lay-submit lay-filter="verifyCommitBtn">提交</button>
        </div>
    </div>
</div>
<script>
    function initVerify(form, obj) {
        //退回
        form.on('submit(backBtn)', function (data) {
            layer.confirm('确定要退回？', {icon: 3, title: '提示'}, function (index) {
                $.get("flowinfomation/updateJobState",
                    "taskid=" + obj.taskid + "&jobstate=" + 4 + "&transmitstate=" + 2, function (result) {
                        if (result.code == 200) {
                            $.ajax({
                                url: "flowinfomation/flowBack",
                                method: "post",
                                data: JSON.stringify(obj),
                                dataType: "json",
                                contentType: "application/json",
                                success: function (result) {
                                    if (result.code == 200) {
                                        layer.msg(result.msg, {icon: 1}, function (index) {
                                            location.reload()
                                        });
                                    } else {
                                        layer.msg(result.msg, {icon: 2});
                                    }
                                }
                            })
                        }
                    })
            });
            return false;
        });
        //提交
        form.on('submit(verifyCommitBtn)', function (data) {
            layer.confirm('确定要通过？', {icon: 3, title: '提示'}, function (index) {
                $.get("flowinfomation/updateJobState",
                    "taskid=" + obj.taskid + "&jobstate=" + 4, function (result) {
                    if (result.code == 200) {
                        var claims = new Object();
                        claims.taskpid = obj.taskid;
                        claims.taskname = '理算';
                        claims.flowid = obj.flowid;
                        claims.claimmainid = obj.claimmainid;

                        $.ajax({
                            url: "flowinfomation/addNextFlow",
                            method: "post",
                            data: JSON.stringify(claims),
                            dataType: "json",
                            contentType: "application/json",
                            success: function (result) {
                                if (result.code == 200) {
                                    layer.msg("已提交核损", {icon: 1}, function () {
                                        location.reload();
                                    });
                                } else {
                                    layer.msg("核损提交异常", {icon: 2})
                                }
                            }
                        })
                    } else {
                        layer.msg("提交核损失败", {icon: 2, time: 1000});
                    }
                });
            });
            return false;
        });
    }
</script>
